import request from '@/utils/request'
import downloadService from "@/utils/downloadService";

// 查询文章列表
export function addArticle(data) {
  return request({
    url: '/content/article',
    method: 'post',
    data: data
  })
}

// 查询文章列表
export function listArticle(query) {
  return request({
    url: '/content/article/list',
    method: 'get',
    params: query
  })
}

// 删除文章
export function delArticle(id) {
  return request({
    url: '/content/article/' + id,
    method: 'delete'
  })
}

// 查询文章详细
export function getArticle(id) {
  return request({
    url: '/content/article/' + id,
    method: 'get'
  })
}

// 修改文章
export function updateArticle(data) {
  return request({
    url: '/content/article',
    method: 'put',
    data: data
  })
}

// 将文章改为发布
export function changeArticleStatus(id, newStatus) {
  return request({
    url: '/content/article/changeArticleStatus',
    method: 'put',
    data: {
      id: id,
      status: newStatus
    }
  })
}

// 导出文章
export function exportArticle() {
  return downloadService({
    url: '/content/article/export',
    method: 'get'
  })
}
